home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / utils / file / logiso.000 / logiso / Utils / RCS / duplicate_dir,v < prev    next >
Encoding:
Text File  |  1995-03-24  |  2.2 KB  |  119 lines

  1. head    1.2;
  2. access;
  3. symbols
  4.     VER_0_3:1.2
  5.     VER_0_2:1.1;
  6. locks; strict;
  7. comment    @# @;
  8.  
  9.  
  10. 1.2
  11. date    95.03.24.11.43.35;    author coulter;    state Exp;
  12. branches;
  13. next    1.1;
  14.  
  15. 1.1
  16. date    95.02.18.08.36.38;    author coulter;    state Exp;
  17. branches;
  18. next    ;
  19.  
  20.  
  21. desc
  22. @duplicate a directory.
  23. @
  24.  
  25.  
  26. 1.2
  27. log
  28. @Checkin version for 0.3 distribution.
  29. @
  30. text
  31. @#! /bin/ksh
  32. USAGE='USAGE: duplicate_dir DIR_PATH MOUNT_PATH MAP_TO
  33.     For every file in directory DIR_PATH, create a symbolic link to
  34.     it by the same name in the current directory.  If the link is
  35.     below MOUNT_PATH, replace it with a linke with MOUNT_PATH
  36.     replace by MAP_TO
  37. '  
  38. # (C) Copyright 1995 by Michael Coulter.  All rights reserved.
  39.  
  40. # define std functions
  41.  
  42.    ISOFS_UTIL_DIR="${ISOFS_UTIL_DIR:-/usr/src/linux/fs/isofs/Utils}"
  43.    . "$ISOFS_UTIL_DIR/ksh_fns"
  44.  
  45.  
  46. # Process parameters
  47.  
  48.    if [ $# -ne 3 ]
  49.    then
  50.       echo "$USAGE" >&2
  51.       echo "3 arguments required.  $# given." >&2
  52.       exit 1
  53.    fi
  54.    if [ ! -d "$1" ]
  55.    then
  56.       echo "$1 is not a directory"
  57.    fi
  58.    DIR_ARG="$1"; shift
  59.    if [ ! -d "$1" ]
  60.    then
  61.       echo "$1 is not a directory"
  62.    fi
  63.    MOUNT_PATH="$1"; shift
  64.    if [ ! -d "$1" ]
  65.    then
  66.       echo "$1 is not a directory"
  67.    fi
  68.    MAP_TO="$1"; shift
  69.  
  70. # Set DIR_PATH to hard path
  71.  
  72.    set -P # print absolut hw path
  73.    HERE="$PWD"
  74.    check_cmd 2 cd "$DIR_ARG"
  75.    DIR_PATH="$PWD"
  76.    check_cmd 3 cd "$HERE"
  77.  
  78. # Do it
  79.  
  80.    PREFIX="${MAP_TO%/}/"
  81.    (cd "$DIR_PATH"; ls -a -1) | while read FILE
  82.    do
  83.       if [ "$FILE" != '.' -a "$FILE" != '..' ]
  84.       then
  85.      DEST_FILE="$(follow_link "${DIR_PATH}/${FILE}")"
  86.      if [ "$DEST_FILE" != "${DEST_FILE#${MOUNT_PATH}}" ]
  87.      then
  88.         # Use equivalent path
  89.         DEST_FILE="${DEST_FILE#${MOUNT_PATH}/}"
  90.         DEST_FILE="${PREFIX}$DEST_FILE"
  91.      fi
  92.      ## echo "HERE is $HERE"
  93.      ## echo "DEST_FILE is $DEST_FILE"
  94.      ## echo "FILE is $FILE"
  95.      ## echo "PWD is $PWD"
  96.      if [ "$DEST_FILE" = "$HERE/$FILE" ]
  97.      then
  98.         ln -s "$DIR_PATH/$FILE" "$FILE"
  99.      else
  100.         # Use relative path if possible
  101.         ## echo "HERE is $HERE"
  102.         ## echo "DEST_FILE is $DEST_FILE"
  103.         DEST_FILE="${DEST_FILE#${HERE}/}"
  104.         ## echo ln -s "$DEST_FILE" "${FILE}"
  105.         ln -s "$DEST_FILE" "${FILE}"
  106.      fi
  107.       fi
  108.    done
  109. @
  110.  
  111.  
  112. 1.1
  113. log
  114. @Checkpoint version before fixing /usr/bin install
  115. @
  116. text
  117. @d8 1
  118. @
  119.